#########################
# Wrote by Chunjun Lee
# Date: 2015-06-09
#########################

target:=libtinySH.a
sources:=$(wildcard *.c)
objects:=$(subst .c,.o,$(sources))
depend:=dependence

CC:=gcc

AR:=ar
ARFLAGS:=rcs

RM:=rm -f

ifeq ($(depend),$(wildcard $(depend)))
all : $(target)
include $(depend)
else
all : $(depend)
endif

$(depend) : $(sources)
	@echo "Make dependence."
	$(CC) -MM $^ > $@
	$(MAKE)

$(target) : $(objects)
	$(AR) $(ARFLAGS) $@ $^

.PHONY : all clean disclean

clean :
	$(RM) $(objects)

distclean : clean
	$(RM) $(target) $(depend)
